********************************************************************************
* Figure: # Bonds issues and Merger covenants
********************************************************************************
clear
use fisdSample_MnA_TRACE_cov_grpd
	keep if in_compu==1
collapse (count) noBond=issue_id (mean) inv_res_umb div_res_umb sub_fin_res_umb event_res_umb merger_res control_change_res event_res, by(yr)
	drop if noBond==.
	local vars inv_res_umb div_res_umb sub_fin_res_umb event_res_umb merger_res control_change_res
	foreach v of local vars{
		replace `v'=`v'*100
	}
	la var noBond "# Bonds"
	la var inv_res_umb "Investment"
	la var div_res_umb "Dividend"
	la var sub_fin_res_umb "Sub. Financing"
	la var event_res_umb "Event"	
	la var merger_res "Merger"
	la var control_change_res "Change in Control"
	
twoway bar noBond yr, fcolor(gs14)   ytitle("# Bonds issued", axis(2)) yaxis(2) yscale(axis(2)) xsc(r(1980 2018)) xlabel(1980[5]2018) ///
	|| line merger_res yr, ytitle("% bonds with restrictions", axis(1)) xsc(r(1980 2018)) xlabel(1980[5]2018)	///
	|| , title("Bonds issued and Covenants ")
graph export "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\figures\newDebt_merger_cov.eps", replace		

********************************************************************************
* TABLE 1: Sample distribution of bond repurchase and covenants
********************************************************************************
clear
use fisdSample_MnA_TRACE_cov_grpd
la var div_res_umb "{Dividend-related Restrictions}"
keep if repurchase==1
    local vars 	inv_res_umb merger_res  direct_inv_res other_Inv_res ///
				div_res_umb ///
				sub_fin_res_umb  ///
				event_res_umb control_change_res other_event_res 
	local opt "replace"
	tempname hh
	file open `hh' using "D:\Dropbox\20.Bond buy backs_Praveen Kumar_Eswar\tex\tables\covenant_dist_allRep_grp.tex", write `opt'
	file write `hh' "\begin{tabular}{l*{3}{l}} \hline \hline" _n
	file write `hh' " {Variable} & {Mean} & {SD} & {N} \\ \hline " _n
	
	foreach v of local vars {
	local label : variable label `v'	
	if "`v'" == "div_res_umb"{
		file write `hh' "\\" _n
	}
	if "`v'" == "sub_fin_res_umb"{
		file write `hh' "\\" _n
	}
	if "`v'" == "event_res_umb"{
		file write `hh' "\\" _n
	}
	
	file write `hh' "`label'" " & "
	
	qui summarize `v' , d
	file write `hh' %9.2fc (r(mean)) " & "
	*file write `hh' %9.2fc (r(p50)) " & "
	*file write `hh' %9.2fc (r(p25)) " & "
	file write `hh' %9.2fc (r(sd)) " & "
	*file write `hh' %9.2fc (r(p75)) " & "
	file write `hh' %9.0fc (r(N)) " \\ " _n
	}
	file write `hh' "\hline \end{tabular}"  _n
	file close `hh'	


********************************************************************************
* Table 2:  Bond repurchase and M&A - Triple interaction DiD
********************************************************************************	
cd "D:\Dropbox\Datasets\TRACE\data"

clear
use gvkey atq lev ret1Qtr calYrQtr cash_at tobinsq using compuData
tempfile compuData
save `compuData'


clear
use repCS_b4Aftr_wFin
	keep issuer_id	permco	gvkey indCode
	duplicates drop
tempfile indCodes
save `indCodes'

* SAMPLE MATCHING
clear
use matchedReps
	rename (calYrQtr_ef openMrkt) (repYrQtr openMrkt_rep_dum)
tempfile matchedReps
save `matchedReps'

clear
use frmYrQtrPanel_repSample	
	gen openMrkt_rep_dum=cond(openMrkt_rep>0&tenderOffer_rep==0,1,0)
	joinby issuer_id gvkey repYrQtr openMrkt_rep_dum using `matchedReps'
	drop openMrkt_rep_dum
	gen fyear=yofd(dofq(calYrQtr))
	merge m:1 gvkey calYrQtr using `compuData', keepusing(atq lev cash_at tobinsq )
	drop if _merge==2
	drop _merge
	gen ln_atq_ =ln(1+atq)
	gen tenderDum=cond(tenderOffer_rep>0,1,0)
	gen post = cond(timeLine>0,1,0)
	
	sort issuer_id permco gvkey repYrQtr timeLine
	local vars inv_res_umb_frac div_res_umb_frac sub_fin_res_umb_frac event_res_umb_frac merger_res_frac lev cash_at
	foreach v of local vars{
		by issuer_id permco gvkey repYrQtr: gen diff_`v'=`v'-`v'[_n-1]
	}

	sort issuer_id permco gvkey repYrQtr repEventID timeLine
	by issuer_id permco gvkey repYrQtr repEventID: egen postAcqrr=sum(acq_dum) if timeLine>0
	replace postAcqrr=0 if postAcqrr==.
	gen postAcq=post*acq_dum 
	gen postTender=post*tenderDum
	gen postTenderAcq=post*tenderDum*acq_dum
	gen acqTender=acq_dum*tenderDum
	merge m:1 issuer_id	permco	gvkey using `indCodes', keepusing(indCode)
	drop if _merge==2
	drop _merge
	
	la var tenderDum "Tender Offer"
	la var post "Post"
	la var postAcq "Post \$ \times \$ Acquirer"
	la var postTender "Post \$ \times \$ Tender Offer"
	la var postTenderAcq "Post \$ \times \$ Tender Offer \$ \times \$ Acquirer"
	la var acq_dum "Acquirer"
	la var acqTender "Tender Offer \$ \times \$ Acquirer"
		
	la var diff_inv_res_umb_frac "Investment"
	la var diff_div_res_umb_frac "Dividend"
	la var diff_sub_fin_res_umb_frac "Subsequent Financing"
	la var diff_event_res_umb_frac "Event"
	la var diff_merger_res_frac "Merger"
	la var diff_lev "Leverage"
	la var diff_cash_at "(Cash/Total Assets)"

	la var inv_res_umb_frac "Investment"
	la var div_res_umb_frac "Dividend"
	la var sub_fin_res_umb_frac "Subsequent Financing"
	la var event_res_umb_frac "Event"
	la var merger_res_frac "Merger"
	la var lev "Leverage"
	la var cash_at "(Cash/Total Assets)"

	la var indirect_Inv_Res_frac "Indirect Investment"
	la var stock_sale_res_frac "Stock Sale"
	la var direct_inv_res_frac "Direct Investment"
	la var inv_res_frac "Investment"
	la var secured_frac "Secured"
	la var div_pay_res_frac "Dividend Payment"
	la var other_pay_res_frac "Other Payment"
	la var subord_deb_issue_res_frac "Subord. Debt Issue"
	la var saleLease_ob_res_frac "Sale/Lease Obligation"
	la var debt_priority_res_frac "Debt Priority"
	la var stock_iss_res_frac "Stock Issuance"
	la var default_res_frac "Default"
	la var control_change_res_frac "Change in Control"
	la var event_res_frac "Events"	
	la var ln_atq_ef "Ln(1+Total Assets\$  _{t-1} \$)"
	la var lev "Leverage\$  _{t-1} \$ "
		
	duplicates drop repEventID issuer_id permco gvkey timeLine, force
	egen firmID=group(repEventID issuer_id permco gvkey)
	tsset firmID timeLine 
	drop if timeLine==-9
save cov_ma_3did, replace	

use cov_ma_3did, clear
estimates clear	
	qui eststo:	areg merger_res_frac post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq l.ln_atq l.lev l.cash_at l.tobinsq    i.calYrQtr  ,  a(gvkey) r cl(indCode) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	estadd local repFE "\$ \checkmark \$"
		
	qui eststo:	areg inv_res_umb_frac post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq l.ln_atq l.lev l.cash_at l.tobinsq   i.calYrQtr    ,  a(gvkey) r cl(indCode) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	estadd local repFE "\$ \checkmark \$"

	qui eststo:	areg div_res_umb_frac post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq l.ln_atq l.lev l.cash_at l.tobinsq   i.calYrQtr    ,  a(gvkey) r cl(indCode) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	estadd local repFE "\$ \checkmark \$"

	qui eststo:	areg sub_fin_res_umb_frac post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq l.ln_atq l.lev l.cash_at l.tobinsq   i.calYrQtr    ,  a(gvkey) r cl(indCode) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	estadd local repFE "\$ \checkmark \$"

	qui eststo:	areg control_change_res_frac post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq l.ln_atq l.lev l.cash_at l.tobinsq  i.calYrQtr    ,  a(gvkey) r cl(indCode) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	estadd local repFE "\$ \checkmark \$"
	
	esttab using "D:\Dropbox\20.Bond buy backs_Praveen Kumar_Eswar\tex\tables\covenant_n_MnA_pnl_ctrls_mtch1_ind.tex", replace  b(3) se(3)  ///
		keep( post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq    ) ///
		order( post tenderDum acq_dum  postTender postAcq acqTender postTenderAcq   ) ///
		depvars  label stats(N rsqA firmFE yrFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
		labels("Obs." "$ Adj.-R^{2} $" "Firm F.E." "Qtr. F.E." )) ///			
		substitute(\_ _) star(* .1 ** .05 *** .01)	
		


********************************************************************************
* Table 3 and 9: Covenant redesign and competitiveness of industry | Cross-sectional regressions: change in covenants, M&A activity, and competition
********************************************************************************		
clear
use repCS_b4Aftr_wFin	
	joinby issuer_id gvkey calYrQtr_ef openMrkt using matchedReps
	sort repQtrID_1 issuer_id issue_id calYrQtr_ef 
	drop atq_ef lev   
	replace calYrQtr_ef=calYrQtr_ef-1
	gen fyear=yofd(dofq(calYrQtr_ef))
	merge m:1 gvkey calYrQtr_ef using compuData, keepusing(atq lev cash_at tobinsq )
	drop if _merge==2
	drop _merge
	replace calYrQtr_ef=calYrQtr_ef+1	
	bysort issuer_id calYrQtr_ef: egen acq=sum(repB4MnA_acq)
	replace acq=1 if acq>0
	sort  gvkey calYrQtr_ef 
	replace repB4MnA_acq=acq
	bysort issuer_id calYrQtr_ef: egen trg=sum(repB4MnA_trg)
	replace trg=1 if trg>0
	sort  gvkey calYrQtr_ef 
	replace repB4MnA_trg=trg
	drop trg acq
	

	local vars merger_res_frac_preQ inv_res_umb_frac_preQ div_res_umb_frac_preQ sub_fin_res_umb_frac_preQ event_res_umb_frac_preQ default_res_frac_preQ control_change_res_frac_preQ event_res_frac_preQ  ///
				nb_merger_res_frac nb_inv_res_umb_frac nb_div_res_umb_frac nb_sub_fin_res_umb_frac nb_event_res_umb_frac nb_default_res_frac nb_control_change_res_frac nb_event_res_frac
	foreach v of local vars{
		replace `v'=0 if `v'==.
	}
	gen calYr=yofd(dofq(calYrQtr_ef))
	gen ln_atq =ln(1+atq)

	gen diff_merger_res_frac=merger_res_frac_p2yr-merger_res_frac_preQ
	gen diff_inv_res_umb_frac=inv_res_umb_frac_p2yr-inv_res_umb_frac_preQ
	gen diff_div_res_umb_frac=div_res_umb_frac_p2yr-div_res_umb_frac_preQ 
	gen diff_sub_fin_res_umb_frac =sub_fin_res_umb_frac_p2yr-sub_fin_res_umb_frac_preQ
	gen diff_event_res_umb_frac=event_res_umb_frac_p2yr-event_res_umb_frac_preQ
	gen diff_default_res_frac=default_res_frac_p2yr-default_res_frac_preQ
	gen diff_control_change_res_frac=control_change_res_frac_p2yr-control_change_res_frac_preQ
	gen diff_event_res_frac=event_res_frac_p2yr-event_res_frac_preQ
	gen diff_lev=lev_p2yr-lev 
	gen diff_cash_at=cash_at_p2yr-cash_at
	

	destring sic_code, gen(sic)
	gen high_tech=0
	replace high_tech=1 if sic==7374 | sic==7376 | sic==7377 | sic==7378 | sic==7379 | sic==3660 | sic==3690 | sic==3691 | sic==3692 | sic==3699 | sic==8730 | sic==8731 | sic==8732 | sic==8733 | sic==8734 
	replace high_tech=1 if indCode48==35 | indCode48==36 | indCode48==37 | indCode48==12 | indCode48==13 | indCode48==32 
		
	tab indCode,gen(ff12_ind)
	forvalues i=1/12{
		replace ff12_ind`i'=0 if ff12_ind`i'==1 & high_tech==1
	}
		
	rename (ff12_ind1 ff12_ind2 ff12_ind3 ff12_ind4 ff12_ind5 ff12_ind6 ff12_ind7 ff12_ind8 ff12_ind9 ff12_ind10 ff12_ind11 ff12_ind12) (NonDurables Durables Manufacturing Energy Chemicals BusEquip Telecoms Utilities Wholesales Healthcare Finance Others)
	gen high_comp=0
	replace high_comp=1 if high_tech==1|Manufacturing==1| Energy==1| Chemicals==1| Wholesales==1| Healthcare==1
	
	gen high_comp_acq=high_comp*repB4MnA_acq
	gen high_comp_trg=high_comp*repB4MnA_trgt 
	gen low_comp_acq=(1-high_comp)*repB4MnA_acq 
	gen low_comp_trg=(1-high_comp)*repB4MnA_trgt	
	gen sic3=real(substr(sic_code,1,3))
	replace cash_at =  0 if cash_at==.
	winsor2 ln_atq_ef lev cash_at tobinsq  , cuts(1 99) replace
	
	merge m:1 indCode48 calYrQtr using wave
	drop if _merge==2
	drop _merge
	replace wavePeriod=0 if wavePeriod==.
	drop high_comp_acq high_comp_trg
	replace treated_acq=0 if treated_acq==.
	replace treated_trg=0 if treated_trg==.
	gen high_comp_acq=treated_acq*high_comp
	gen high_comp_trg=treated_trg*high_comp

	merge m:1 sic calYr using ntrgap
	drop if _merge==2
	gen ntr_sample=cond(_merge==3,1,0)
	drop _merge
	replace ntrgap=0 if ntrgap==.
	replace ntr_sample=0 if ntrgap==0
	gen high_ntr=cond(ntrgap>0.3125,1,0)
	gen high_ntr_post=cond(high_ntr==1 & calYr>2001,1,0)
	gen ntr_sample_post=cond(ntr_sample==1 & calYr>2001,1,0)
	gen post_2001 =cond(calYr>2001,1,0)
	gen wave_acq=treated_acq*wavePeriod
	gen wave_trg=treated_trg*wavePeriod
	
	merge m:1 permco calYrQtr_ef using acq_within_2yrs
	drop if _merge==2
	drop _merge
	merge m:1 permco calYrQtr_ef using trg_within_2yrs
	drop if _merge==2
	drop _merge
	
	local vars cross_acquirer diff_sic4_acq diff_sic3_acq cross_country_acq cross_target diff_sic4_trg diff_sic3_trg cross_country_trg
	foreach v of local vars{
		replace `v'=0 if `v'==.
		gen dum_`v'=cond(`v'>0 & `v'!=.,1,0)
	}
	
	
	gen dum_same_sic4_acq=cond(repB4MnA_acq==1 & dum_diff_sic4_acq==0,1,0)
	gen dum_same_sic4_trg=cond(repB4MnA_trg==1 & dum_diff_sic4_trg==0,1,0)
	gen dum_same_country_acq = cond(repB4MnA_acq==1 & dum_cross_country_acq==0,1,0) 
	gen dum_same_country_trg = cond(repB4MnA_trg==1 & dum_cross_country_trg==0,1,0)  

	gen high_ntr_post_acq=high_ntr_post*treated_acq
	gen high_ntr_acq=high_ntr*treated_acq
	gen post_2001_acq=post_2001*treated_acq

	gen high_ntr_post_trg=high_ntr_post*treated_trg
	gen high_ntr_trg=high_ntr*treated_trg
	gen post_2001_trg=post_2001*treated_trg
	
	merge m:1 sic using internet_sics
	drop if _merge==2
	drop _merge
	replace internet=0 if internet==.
 	gen post_2005=cond(calYr>2005,1,0)	
	gen yr_2005m=cond(yr<=2005,1,0)
	gen yr_2006=cond(yr==2006,1,0)
	gen yr_2007=cond(yr==2007,1,0)
	gen yr_2008=cond(yr==2008,1,0)
	gen yr_2009=cond(yr==2009,1,0)
	gen yr_2010=cond(yr==2010,1,0)
	gen yr_2011p=cond(yr>2010,1,0)
	
	replace treated_acq=0 if treated_acq==.
	replace treated_trg =0 if treated_trg  ==.
	gen post_2005_int=internet*post_2005
	gen post_2005_int_acq=internet*post_2005*treated_acq
	gen post_2005_int_trg=internet*post_2005*treated_trg  
	
	la var internet "Cloud Computing Affected"
	la var post_2005 "Post-2005"
	la var post_2005_int "Post-2005 \$ \times \$ Cloud Computing Affected" 
	la var post_2005_int_trg "Post-2005 \$ \times \$ Cloud Computing Affected Acquirer "  
	la var post_2005_int_acq "Post-2005 \$ \times \$ Cloud Computing Affected Target" 
	la var treated_acq "Acquirer"
	la var treated_trg "Target"
	la var wave_acq "M\&A Wave Qtr. \$ \times \$ Acquirer"
	la var wave_trg "M\&A Wave Qtr. \$ \times \$ Target"
	la var wavePeriod "M\&A Wave Qtr."	
	la var high_comp "High competition"
	la var ntr_sample_post "Post-2001 \$ \times \$ High NTR Gap"
	la var high_ntr_post "Post-2001 \$ \times \$ High NTR Gap"
	la var high_ntr_post_acq "Post-2001 \$ \times \$ High NTR Gap Acquirer"
	la var high_ntr_post_trg "Post-2001 \$ \times \$ High NTR Gap Target"
	la var treated_acq "Acquirer"
	la var treated_trg "Target"
	la var dum_cross_country_acq "Cross Country Acquirer"
	la var dum_cross_country_trg "Cross Country Target"
	la var dum_diff_sic4_acq "Cross Industry Acquirer"
	la var dum_diff_sic4_trg "Cross Industry Target"
	la var dum_same_sic4_acq "Same Industry Acquirer"
	la var dum_same_sic4_trg "Same Industry Target"
	la var dum_same_country_acq "Same Country Acquirer"
	la var dum_same_country_trg "Same Country Target"
	la var high_comp_acq "High Competition Acquirer"
	la var high_comp_trg "High Competition Target"
	la var low_comp_acq "Low comp. acquirer"
	la var low_comp_trg "Low comp. target"
	la var diff_merger_res_frac "\$ \Delta \$ Merger"
	la var diff_inv_res_umb_frac "\$ \Delta \$ Investment"
	la var diff_div_res_umb_frac "\$ \Delta \$ Dividend"
	la var diff_sub_fin_res_umb_frac "\$ \Delta \$ Subsequent Financing" 
	la var diff_event_res_umb_frac "\$ \Delta \$ Event"
	la var diff_default_res_frac "\$ \Delta \$ Default"
	la var diff_control_change_res_frac "\$ \Delta \$ Change in Control"
	la var diff_event_res_frac "\$ \Delta \$ Events"
	la var diff_lev "\$ \Delta \$ Leverage"
	la var diff_cash_at "\$ \Delta \$ (Cash/Total Assets)"
*save cov_redesign_comp, replace		


estimates clear	
	eststo:	reghdfe diff_merger_res_frac treated_acq high_comp high_comp_acq ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_merger_res_frac treated_acq high_ntr high_ntr_post post_2001 high_ntr_post_acq high_ntr_acq post_2001_acq ln_atq lev cash_at tobinsq if openMrkt==0,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_merger_res_frac wave_acq treated_acq wavePeriod ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_merger_res_frac dum_diff_sic4_acq dum_same_sic4_acq treated_acq ln_atq lev  cash_at tobinsq  if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"		
	eststo:	reghdfe diff_merger_res_frac dum_cross_country_acq dum_same_country_acq treated_acq ln_atq lev  cash_at tobinsq  if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\merger_cov_regs.tex", replace  b(3) se(3)  ///
	keep(  high_comp_acq high_ntr_post_acq  wave_acq dum_diff_sic4_acq dum_cross_country_acq  ) ///
	order( high_comp_acq high_ntr_post_acq wave_acq dum_diff_sic4_acq dum_cross_country_acq ) ///
	mgroups(" \$ \Delta Merger \$ " , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars  nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		

	

estimates clear	
	eststo:	reghdfe diff_inv_res_umb_frac treated_acq high_comp high_comp_acq ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_inv_res_umb_frac ln_atq lev cash_at tobinsq  treated_acq high_ntr high_ntr_post post_2001 high_ntr_post_acq high_ntr_acq post_2001_acq if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_inv_res_umb_frac wave_acq treated_acq wavePeriod  ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_inv_res_umb_frac dum_diff_sic4_acq dum_same_sic4_acq treated_acq ln_atq lev   cash_at tobinsq if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"		
	eststo:	reghdfe diff_inv_res_umb_frac dum_cross_country_acq dum_same_country_acq treated_acq ln_atq lev  cash_at tobinsq  if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\inv_cov_regs.tex", replace  b(3) se(3)  ///
	keep(  high_comp_acq high_ntr_post_acq  wave_acq dum_diff_sic4_acq dum_same_sic4_acq dum_cross_country_acq  dum_same_country_acq  ) ///
	order( high_comp_acq high_ntr_post_acq wave_acq dum_diff_sic4_acq dum_same_sic4_acq dum_cross_country_acq dum_same_country_acq ) ///
	mgroups(" \$ \Delta Investment \$ " , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars  nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		

	
		
estimates clear	
	eststo:	reghdfe diff_div_res_umb_frac treated_acq high_comp high_comp_acq ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_div_res_umb_frac ln_atq lev cash_at tobinsq  treated_acq high_ntr high_ntr_post post_2001 high_ntr_post_acq high_ntr_acq post_2001_acq if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_div_res_umb_frac wave_acq treated_acq wavePeriod   wave_trg  ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_div_res_umb_frac dum_diff_sic4_acq dum_same_sic4_acq treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"		
	eststo:	reghdfe diff_div_res_umb_frac dum_cross_country_acq dum_same_country_acq  treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\div_cov_regs.tex", replace  b(3) se(3)  ///
	keep(  high_comp_acq high_ntr_post_acq  wave_acq dum_diff_sic4_acq dum_cross_country_acq  ) ///
	order( high_comp_acq high_ntr_post_acq wave_acq dum_diff_sic4_acq dum_cross_country_acq ) ///
	mgroups(" \$ \Delta Dividend \$ " , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars  nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)			
	
		
estimates clear	
	eststo:	reghdfe diff_sub_fin_res_umb_frac treated_acq high_comp high_comp_acq ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_sub_fin_res_umb_frac ln_atq lev cash_at tobinsq  treated_acq high_ntr high_ntr_post post_2001 high_ntr_post_acq high_ntr_acq post_2001_acq if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_sub_fin_res_umb_frac wave_acq treated_acq wavePeriod   ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_sub_fin_res_umb_frac dum_diff_sic4_acq dum_same_sic4_acq treated_acq ln_atq lev  cash_at tobinsq  if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"		
	eststo:	reghdfe diff_sub_fin_res_umb_frac dum_cross_country_acq dum_same_country_acq treated_acq ln_atq lev  cash_at tobinsq  if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\subfin_cov_regs.tex", replace  b(3) se(3)  ///
	keep(  high_comp_acq high_ntr_post_acq  wave_acq dum_diff_sic4_acq dum_cross_country_acq  ) ///
	order( high_comp_acq high_ntr_post_acq wave_acq dum_diff_sic4_acq dum_cross_country_acq ) ///
	mgroups(" \$ \Delta Subsequent \: Financing \$ " , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars  nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		
	
	

estimates clear	
	eststo:	reghdfe diff_control_change_res_frac treated_acq high_comp high_comp_acq ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_control_change_res_frac ln_atq lev cash_at tobinsq  treated_acq high_ntr high_ntr_post post_2001 high_ntr_post_acq high_ntr_acq post_2001_acq if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_control_change_res_frac wave_acq treated_acq wavePeriod   ln_atq lev cash_at tobinsq  if openMrkt==0	,  a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
	eststo:	reghdfe diff_control_change_res_frac dum_diff_sic4_acq dum_same_sic4_acq treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"		
	eststo:	reghdfe diff_control_change_res_frac dum_cross_country_acq dum_same_country_acq treated_acq ln_atq lev  cash_at tobinsq   if openMrkt==0, a(indCode48 	calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\cic_cov_regs.tex", replace  b(3) se(3)  ///
	keep(  high_comp_acq high_ntr_post_acq  wave_acq dum_diff_sic4_acq dum_cross_country_acq  ) ///
	order( high_comp_acq high_ntr_post_acq wave_acq dum_diff_sic4_acq dum_cross_country_acq ) ///
	mgroups(" \$ \Delta Change \: in \: Control \$ " , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars  nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		

	
		
estimates clear
	eststo:	reghdfe diff_merger_res_frac internet post_2005 post_2005_int post_2005_int_acq treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_inv_res_umb_frac internet post_2005 post_2005_int post_2005_int_acq post_2005_int_trg treated_acq treated_trg  ln_atq lev cash_at tobinsq   if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_div_res_umb_frac internet post_2005 post_2005_int post_2005_int_acq ln_atq lev cash_at tobinsq   if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_sub_fin_res_umb_frac internet post_2005 post_2005_int post_2005_int_acq treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe diff_control_change_res_frac internet post_2005 post_2005_int post_2005_int_acq treated_acq ln_atq lev cash_at tobinsq   if openMrkt==0	,  a(indCode48 calYrQtr_ef) vce(r)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\cs_cov_aws_reg.tex", replace  b(3) se(3)  ///
		keep(post_2005_int_acq treated_acq ) ///
		order(post_2005_int_acq treated_acq  ) ///
		depvars  label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
		labels("Obs." "$ Adj.-R^{2} $"   "Repurchase Qtr. F.E." "Industry F.E.")) ///			
		substitute(\_ _) star(* .1 ** .05 *** .01)			
				

				
****************************************************************************************************************************************************************
* TABLE 4 & 5: Likelihood of bond repurchases: Firm and M\&A characteristics | Likelihood of bond repurchase
****************************************************************************************************************************************************************


* Treasury rates
clear
use treasuryYields
	gen intLevel=yr_10
	gen intSlope=yr_10-mo_3
	gen calYrQtr_ef=yq(year(mdy(month,day,year)), quarter(mdy(month,day,year)))
	format %tq calYrQtr
tempfile yields	
save `yields'

* Get Investment Grade and Industry variables
clear
use fisdSample_MnA_TRACE_cov
	gen invGrd_DPR=cond(trim(ratingDPR)=="A" | trim(ratingDPR)=="A+" | trim(ratingDPR)=="A-" | trim(ratingDPR)=="AA-" | trim(ratingDPR)=="BBB" | trim(ratingDPR)=="BBB+" | trim(ratingDPR)=="BBB-",1,0)
	gen invGrd_FR=cond(trim(ratingFR)=="A" | trim(ratingFR)=="A+" | trim(ratingFR)=="A-" | trim(ratingFR)=="AA" | trim(ratingFR)=="AA+" | trim(ratingFR)=="AA-" | trim(ratingFR)=="AAA" | trim(ratingFR)=="BBB" | trim(ratingFR)=="BBB+" | trim(ratingFR)=="BBB-",1,0)
	gen invGrd_MR=cond(trim(ratingMR)=="A1"|trim(ratingMR)=="A2"|trim(ratingMR)=="A3"|trim(ratingMR)=="Aa1"|trim(ratingMR)=="Aa2"|trim(ratingMR)=="Aa3"|trim(ratingMR)=="Aaa"|trim(ratingMR)=="Baa1"|trim(ratingMR)=="Baa2"|trim(ratingMR)=="Baa3",1,0)
	gen invGrd_SPR=cond(trim(ratingSPR)=="A" | trim(ratingSPR)=="A+" | trim(ratingSPR)=="A-" | trim(ratingSPR)=="AA" | trim(ratingSPR)=="AA+" | trim(ratingSPR)=="AA-" | trim(ratingSPR)=="AAA" | trim(ratingSPR)=="BBB" | trim(ratingSPR)=="BBB+" | trim(ratingSPR)=="BBB-",1,0)
	
	* Correction to unclassify unrated and missing as Non-investment grade bonds
	replace invGrd_DPR=. if trim(ratingDPR)=="NR" | trim(ratingDPR)=="" 
	replace invGrd_FR=. if trim(ratingFR)=="NR" | trim(ratingFR)==""  
	replace invGrd_MR=. if trim(ratingMR)=="NR" | trim(ratingMR)==""
	replace invGrd_SPR=. if trim(ratingSPR)=="NR" | trim(ratingSPR)==""
	
	egen sumInvGrade=rowtotal(invGrd_DPR invGrd_FR invGrd_MR invGrd_SPR), m
	gen invGrd=cond(sumInvGrade>0,1,0) if sumInvGrade!=.
	keep issuer_id issue_id indCode indCode48 invGrd
	duplicates drop 
tempfile issue_IndNRating
save `issue_IndNRating'



* Merge variables with Issue-Qtr panel for Repurchase & M&A prediction tests.
clear
use frmYrQtrPanel_issueSample
	merge m:1 issuer_id issue_id using `issue_IndNRating', keepusing(indCode indCode48 invGrd)
	drop if _merge==2
	drop _merge
	
	rename calYrQtr_ef calYrQtr
	merge m:1 indCode48 calYrQtr using `wave'
	drop if _merge==2
	drop _merge
	replace wavePeriod=0 if wavePeriod==.
	
	merge m:1 calYrQtr_ef using `yields', keepusing(intLevel intSlope)
	drop if _merge==2
	drop _merge
	
	merge m:1 gvkey calYrQtr_ef using compuData, keepusing(atq mb lev cash_at intCovRatio currRatio opCFRatio tobinsq roa)	
	drop if _merge==2
	drop _merge
	winsor2 (atq mb lev intCovRatio currRatio opCFRatio cash_at tobinsq), cuts(1 99) replace	
	
	gen repurchase_dum = cond(repurchase>0 & repurchase!=.,1,0)
	gen ln_atq =ln(1+atq)
	egen issueID=group(issuer_id gvkey issue_id )	
save predictTestSample, replace	


* Acquirors
clear
use sdcMnA_linked
	rename permco_acq permco
	destring pct_owned_after_trans trans_value, i("-" "," "np") replace
	keep if status=="Completed" | status=="Withdrawn"
	keep if pct_owned_after_trans !=. & pct_owned_after_trans >=100
	keep if trans_value>=1 & trans_value!=.
	gen calYrQtr_ef=yq(year(dateannounced), quarter(dateannounced))
	format %tq calYrQtr
	drop if permco==.
	gen noAcq=1
	collapse (sum) noAcq stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer , by(permco calYrQtr_ef)
	fillin permco calYrQtr_ef
	local vars noAcq stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer 
	foreach v of local vars{
		replace `v'=0 if `v'==. & _fillin==1
	}
	rangestat (sum) noAcq stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer, interval(calYrQtr_ef 0 8) by(permco)
	drop noAcq stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer
	rename (noAcq_sum stock_swap_sum fin_borrowing_sum fin_common_stock_sum fin_debt_sum fin_bridge_loan_sum fin_foreign_lender_sum fin_int_funds_sum fin_junk_bonds_sum fin_credit_line_sum fin_mez_credit_sum fin_pref_stock_sum fin_rights_offer_sum fin_staple_offer_sum debt_restructure_sum debt_offer_sum) (noAcq stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer)
	
	local vars stock_swap fin_borrowing fin_common_stock fin_debt fin_bridge_loan fin_foreign_lender fin_int_funds fin_junk_bonds fin_credit_line fin_mez_credit fin_pref_stock fin_rights_offer fin_staple_offer debt_restructure debt_offer
	foreach v of local vars{
		rename `v' `v'_acq
	}
tempfile acqQtrs
save `acqQtrs'

	
	
use predictTestSample, clear
	collapse (sum) repurchase_dum tenderOffer_dum=tenderOffer openMrkt_dum=openMrkt (median) callDum invGrd remainMaturity intLevel intSlope ln_atq mb lev intCovRatio opCFRatio wavePeriod roa tobinsq, by(permco calYrQtr_ef )
	merge m:1 permco calYrQtr_ef using predictTestSample, keepusing(gvkey)
	drop if _merge==2
	drop _merge
	merge m:1 permco calYrQtr_ef using `acqQtrs'
	drop if _merge==2
	drop _merge
	replace repurchase_dum=1 if repurchase_dum>0 & repurchase_dum!=. 
	replace tenderOffer_dum=1 if tenderOffer_dum>0 & tenderOffer_dum!=. 
	replace openMrkt_dum=1 if openMrkt_dum>0 & openMrkt_dum!=. 
	gen yr = year(dofq(calYrQtr))
	tsset permco calYrQtr_ef
	gen intLevel_lag=l.intLevel 
	gen intSlope_lag=l.intSlope 
	gen atq_lag=l.ln_atq 
	gen mb_lag=l.mb 
	gen roa_lag=l.roa 
	gen lev_lag=l.lev 
	gen intCovRatio_lag=l.intCovRatio 
	gen opCFRatio_lag=l.opCFRatio
	gen tobinsq_lag=l.tobinsq
	gen cash_at_lag=l.cash_at 

	merge m:1 gvkey calYrQtr_ef using compuData, keepusing(roa mb tobinsq gpm sgaq_atq capxy_atq npm ln_lag_atq lag_roa lag_tobinsq lag_gpm lag_mb_1 lag_sgaq_atq lag_capxy_atq lag_npm cogsq_saleq xsgaq_saleq lag_cogsq_saleq lag_xsgaq_saleq xsgay_saleq cogsy_saleq lag_cogsy_saleq lag_xsgay_saleq)	
	drop if _merge==2
	drop _merge
	
	merge m:1 permco using industry, keepusing(sic_code indCode indCode48)
	drop if _merge==2
	drop _merge
	
	destring sic_code, gen(sic)
	gen high_tech=0
	replace high_tech=1 if sic==7374 | sic==7376 | sic==7377 | sic==7378 | sic==7379 | sic==3660 | sic==3690 | sic==3691 | sic==3692 | sic==3699 | sic==8730 | sic==8731 | sic==8732 | sic==8733 | sic==8734 
	replace high_tech=1 if indCode48==35 | indCode48==36 | indCode48==37 | indCode48==12 | indCode48==13 | indCode48==32 
		
	tab indCode,gen(ff12_ind)
	forvalues i=1/12{
		replace ff12_ind`i'=0 if ff12_ind`i'==1 & high_tech==1
	}
		
	rename (ff12_ind1 ff12_ind2 ff12_ind3 ff12_ind4 ff12_ind5 ff12_ind6 ff12_ind7 ff12_ind8 ff12_ind9 ff12_ind10 ff12_ind11 ff12_ind12) (NonDurables Durables Manufacturing Energy Chemicals BusEquip Telecoms Utilities Wholesales Healthcare Finance Others)
	gen high_comp=0
	replace high_comp=1 if high_tech==1|Manufacturing==1| Energy==1| Chemicals==1| Wholesales==1| Healthcare==1
	
	gen calYr=year(dofq(calYrQtr_ef))
	merge m:1 sic calYr using ntrgap
	drop if _merge==2
	gen ntr_sample=cond(_merge==3,1,0)
	drop _merge
	replace ntrgap=0 if ntrgap==.
	replace ntr_sample=0 if ntrgap==0
	tabstat ntrgap, c(s) s(me min p1 p5 p25 p50 p75 p90 p95 p99 max N)
	gen high_ntr=cond(ntrgap>0.3125,1,0)
	gen high_ntr_post=cond(high_ntr==1 & calYr>2001,1,0)
	gen ntr_sample_post=cond(ntr_sample==1 & calYr>2001,1,0)
	gen post_2001 =cond(calYr>2001,1,0)
	 
	gen noAcq_dum=cond(noAcq>0 & noAcq!=.,1,0)	
	replace wavePeriod=1 if wavePeriod!=. & wavePeriod>0
	
	gen high_comp_atq=high_comp*atq_lag
	gen high_comp_mb=high_comp*lag_mb_1
	gen high_comp_roa=high_comp*roa_lag
	gen high_comp_capx=high_comp*lag_capxy_atq
	gen high_comp_sga=high_comp*lag_xsgay_saleq
	gen high_comp_sgaa=high_comp*lag_sgaq_atq
	
	gen wave_atq=wavePeriod*atq_lag
	gen wave_mb=wavePeriod*lag_mb_1
	gen wave_roa=wavePeriod*roa_lag
	gen wave_capx=wavePeriod*lag_capxy_atq
	gen wave_sga=wavePeriod*lag_xsgay_saleq
	gen wave_sgaa=wavePeriod*lag_sgaq_atq
	
	merge m:1 permco calYrQtr_ef using acq_within_2yrs
	drop if _merge==2
	drop _merge
	
	local vars cross_acquirer diff_sic4_acq diff_sic3_acq cross_country_acq 
	foreach v of local vars{
		replace `v'=0 if `v'==.
		gen dum_`v'=cond(`v'>0 & `v'!=.,1,0)
	}
		
	gen dum_same_sic4_acq=cond(dum_diff_sic4_acq>0 & dum_diff_sic4_acq!=.,1,0)
	gen dum_same_country_acq = cond(dum_cross_country_acq>0 & dum_cross_country_acq!=. ,1,0) 

	local vars noAcq stock_swap_acq fin_borrowing_acq fin_common_stock_acq fin_int_funds_acq 
	foreach v of local vars{
		gen `v'_h=`v'*high_comp
		gen `v'_n=`v'*high_ntr_post
		gen `v'_w=`v'*wavePeriod
}
winsor2 lag_mb roa_lag lag_gpm lag_npm lag_sgaq_atq lag_cogsq_saleq lag_xsgaq_saleq cogsq_saleq xsgaq_saleq lag_cogsy_saleq lag_xsgay_saleq lag_capxy_atq, cuts(1 99) replace
	
	la var high_comp "High competition"
	la var high_comp_atq "High Competition \$ \times \$ Size"
	la var high_comp_roa "High Competition \$ \times \$ ROA"
	la var high_comp_sga "High Competition \$ \times \$ SGA/Assets"
	la var dum_same_sic4_acq "Cross Industry Acquirer"
	la var dum_same_country_acq "Cross Country Acquirer"
	la var high_comp "High Competition $ \times $ Acquirer"
	la var high_ntr_post "Post $ \times $ High NTR Gap $ \times $ Acquirer"
	la var wavePeriod "M\&A Wave Qtr. $ \times $ Acquirer"
	la var tenderOffer_dum "Tender Offer"
	la var openMrkt_dum "Open Market"
	la var noAcq_dum  "Acquisition"
save predict_to_MnA_chars, replace


estimates clear	
	eststo: reghdfe tenderOffer_dum high_comp_atq high_comp atq_lag callDum invGrd remainMaturity intLevel_lag intSlope_lag lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag , a( calYrQtr_ef indCode48) vce(cl indCode48)	
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe tenderOffer_dum  high_comp_roa high_comp roa_lag callDum invGrd remainMaturity intLevel_lag intSlope_lag  lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag , a( calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe tenderOffer_dum  high_comp_sga high_comp lag_xsgay_saleq callDum invGrd remainMaturity intLevel_lag  intSlope_lag cash_at_lag tobinsq_lag lev_lag intCovRatio_lag opCFRatio_lag, a( calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe noAcq_dum  high_comp_atq high_comp atq_lag callDum invGrd remainMaturity intLevel_lag intSlope_lag lev_lag  cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag , a( calYrQtr_ef indCode48) vce(cl indCode48) 	
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe noAcq_dum  high_comp_roa high_comp roa_lag callDum invGrd remainMaturity intLevel_lag intSlope_lag lev_lag  cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag , a( calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe noAcq_dum  high_comp_sga high_comp lag_sgaq_atq callDum invGrd remainMaturity intLevel_lag intSlope_lag lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag, a( calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	
esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\predict_w_high_comp_2.tex", replace  b(3) se(3)  ///
	keep( high_comp_atq high_comp_roa high_comp_sga ) ///
	order(high_comp_atq high_comp_roa high_comp_sga ) ///
	mgroups("Tender offer" "Acquisition" , pattern(1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nodepvars nomtitles label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)				



estimates clear	
	qui eststo: reghdfe tenderOffer_dum   callDum invGrd remainMaturity intLevel_lag intSlope_lag atq_lag lev_lag  cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag high_comp high_comp_acq noAcq_dum   , a(gvkey calYrQtr_ef) vce(cl gvkey)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE " \xmark "		
	qui eststo: reghdfe tenderOffer_dum   callDum invGrd remainMaturity intLevel_lag intSlope_lag atq_lag lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag  noAcq_dum  high_ntr high_ntr_post post_2001 high_ntr_post_acq, a(gvkey  calYrQtr_ef) vce(cl gvkey)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"	
	eststo: reghdfe tenderOffer_dum   callDum invGrd remainMaturity intLevel_lag intSlope_lag atq_lag lev_lag  cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag wavePeriod noAcq_dum  wavePeriod_acq , a(gvkey calYrQtr_ef) vce(cl gvkey)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"
	eststo: reghdfe tenderOffer_dum   callDum invGrd remainMaturity intLevel_lag intSlope_lag atq_lag lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag dum_diff_sic4_acq noAcq_dum   , a(gvkey calYrQtr_ef) vce(cl gvkey)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"	
eststo: reghdfe tenderOffer_dum callDum invGrd remainMaturity intLevel_lag intSlope_lag atq_lag lev_lag cash_at_lag tobinsq_lag intCovRatio_lag opCFRatio_lag dum_diff_country_acq noAcq_dum   , a(gvkey calYrQtr_ef) vce(cl gvkey)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local firmFE "\$ \checkmark \$"		
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\rep_predict_3.tex", replace  b(3) se(3)  ///
	keep( high_comp_acq high_ntr_post_acq wavePeriod_acq dum_diff_sic4_acq dum_diff_country_acq ) ///
	order(high_comp_acq high_ntr_post_acq wavePeriod_acq dum_diff_sic4_acq dum_diff_country_acq ) ///
	mgroups("Tender Offer" , pattern(1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  ///
	nomtitles nodepvars  label stats(N rsqA yrFE  firmFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Firm F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)			
	

	
	
**********************************************************************************************************************************************
* Tables 6 & 7: CAR and Premium tables with Competition - collated by hand
**********************************************************************************************************************************************

use predictTestSample, clear
	*collapse (sum) repurchase_dum tenderOffer openMrkt (median) callDum invGrd remainMaturity intLevel intSlope ln_atq mb lev intCovRatio opCFRatio wavePeriod roa, by(permco calYrQtr_ef issuer_id)
	*egen issuerID=group(issuer_id gvkey)
	collapse (sum) repurchase_dum tenderOffer_dum=tenderOffer openMrkt_dum=openMrkt (max) callDum invGrd remainMaturity intLevel intSlope ln_atq lev cash_at tobinsq intCovRatio opCFRatio wavePeriod roa indCode indCode48, by(permco calYrQtr_ef )
tempfile fin_vars
save `fin_vars'

* Deal Value
clear
use sdcMnA_deal_value
	bysort trg_name trg_nation acq_name acq_nation dateannounced permco_acq permco_trgt acq_parent_cusip trg_parent_cusip acqcusip trgtcusip status: gen dup=cond(_N==1,0,_N) 
	tab dup
	drop if dup>0
	gen trans_value1=real(trans_value)
	gen entp_value1=real(entp_value) 
	gen equity_value1=real(equity_value)
	drop trans_value entp_value equity_value 
	rename (trans_value1 entp_value1 equity_value1) (trans_value entp_value equity_value)
	rename (trg_name trg_nation acq_name acq_nation acq_parent_cusip trg_parent_cusip ) (trgtname trgtnation acqname acqnation acqparentcusip trgtparentcusip ) 
tempfile deal_value
save `deal_value'

* Keep PERMCOs in bond sample
clear
use permco using fisProcess
	duplicates drop 
tempfile permcos	
save `permcos'

* Identify sample M&A Activity

clear
use sdcMnA_events
	rename permco_acq permco
	merge m:1 permco using `permcos'
	keep if _merge==3
	drop _merge
	joinby permco using fisProcess, unm(b)
	keep if _merge == 3
	drop _merge
	gen check = dateannounced-effective_date
	gen chngB4MnA_acq=cond(check>0&check<=730,1,0)
	keep if chngB4MnA_acq==1
	gen repB4MnA_acq=cond(action_type=="IRP" | action_type=="T",1,0) if chngB4MnA_acq==1
	replace repB4MnA_acq=0 if repB4MnA_acq==.
	gen toB4MnA_acq=cond(action_type=="T",1,0) if chngB4MnA_acq==1
	gen opB4MnA_acq=cond(action_type=="IRP",1,0) if chngB4MnA_acq==1
	keep if repB4MnA_acq==1
	gen to_date=dateannounced if toB4MnA_acq==1
	gen op_date=dateannounced if opB4MnA_acq==1
	collapse (min) chngB4MnA_acq effective_date  op_date to_date (max) repB4MnA_acq toB4MnA_acq opB4MnA_acq, by (trgtname trgtstate trgtnation acqname acqstate acqnation status pctownedafter acqcusip trgtcusip dateannounced dateeffective)
tempfile MnA_reps	
save `MnA_reps'


clear
use sdcMnA_linked
	gen calYrQtr_ef=qofd(dateannounced )
	format %tq calYrQtr_ef
	merge m:1 permco_acq permco_trgt gvkey_acq gvkey_trgt  dateannounced using base_file, keepusing(diff_sic4 diff_sic3 cross_country)
	drop if _merge==2
	drop _merge		
	merge m:1 trgtname trgtnation acqname acqnation acqparentcusip trgtparentcusip   dateannounced permco_acq permco_trgt acqcusip trgtcusip status using `deal_value', keepusing(trans_value entp_value equity_value)
	drop if _merge==2
	drop _merge
	rename permco_acq permco
	
	merge m:1 permco using `permcos'
	keep if _merge==3
	drop _merge
	
	merge m:1 permco calYrQtr_ef using `fin_vars', keepusing(ln_atq mb lev cash_at tobinsq wavePeriod roa indCode indCode48)
	drop if _merge==2
	drop _merge
	
	merge m:1 trgtname trgtstate trgtnation acqname acqstate acqnation status pctownedafter acqcusip trgtcusip dateannounced dateeffective using `MnA_reps', keepusing(chngB4MnA_acq effective_date  op_date to_date repB4MnA_acq toB4MnA_acq opB4MnA_acq)
	drop if _merge==2
	drop _merge
	replace repB4MnA_acq=0 if repB4MnA_acq==.
	replace toB4MnA_acq=0 if toB4MnA_acq==. 
	replace opB4MnA_acq=0 if opB4MnA_acq==.
	drop if year(dateannounced)<1993
	drop if year(dateannounced)>2019
	destring pctsharesacq pctownedafter pctsought, i(-) replace
	
	merge m:1 indCode48 calYrQtr_ef using wave
	drop if _merge==2
	drop _merge
	replace wavePeriod=0 if wavePeriod==.
	
	rename dateannounced newDate 
	gen dayofweek=dow(newDate)	
	replace newDate=newDate+1 if dayofweek==0
	replace newDate=newDate+2 if dayofweek==6
	
	merge m:1 permco newDate using stockReturns_bnd_frms, keepusing(cum_ret1 cum_ret1_vw cum_ret1_ew cum_ret3 cum_ret3_vw cum_ret3_ew cum_ret30 cum_ret30_vw cum_ret30_ew cum_ret60 cum_ret60_vw cum_ret60_ew)
	drop if _merge == 2	
	*keep if _merge==4
	gen miss=cond(_merge==1,1,0)
	drop _merge
			   
	local vars cum_ret1 cum_ret1_vw cum_ret1_ew cum_ret3 cum_ret3_vw cum_ret3_ew cum_ret30 cum_ret30_vw cum_ret30_ew cum_ret60 cum_ret60_vw cum_ret60_ew
	foreach  v of local vars{
		rename `v' `v'_base
	}
	
	replace newDate=newDate+1 if miss==1

	drop dayofweek
	gen dayofweek=dow(newDate)	
	replace newDate=newDate+1 if dayofweek==0
	replace newDate=newDate+2 if dayofweek==6
														   
	merge m:1 permco newDate using stockReturns_bnd_frms, keepusing(cum_ret1 cum_ret1_vw cum_ret1_ew cum_ret3 cum_ret3_vw cum_ret3_ew cum_ret30 cum_ret30_vw cum_ret30_ew cum_ret60 cum_ret60_vw cum_ret60_ew)
	drop if _merge == 2	
	drop _merge
	
	merge m:1 trgtname trgtstate trgtnation acqname acqstate acqnation status pctownedafter acqcusip trgtcusip dateannounced dateeffective using sdcMnA_linked_premium, keepusing(premium_1d premium_1w premium_4w)
		drop if _merge==2
		drop _merge	
	
	gen sic = real(acqprisic)
	gen high_tech=0
	replace high_tech=1 if sic==7374 | sic==7376 | sic==7377 | sic==7378 | sic==7379 | sic==3660 | sic==3690 | sic==3691 | sic==3692 | sic==3699 | sic==8730 | sic==8731 | sic==8732 | sic==8733 | sic==8734 
	replace high_tech=1 if indCode48==35 | indCode48==36 | indCode48==37 | indCode48==12 | indCode48==13 | indCode48==32 
		
	tab indCode,gen(ff12_ind)
	forvalues i=1/12{
		replace ff12_ind`i'=0 if ff12_ind`i'==1 & high_tech==1
	}
		
	rename (ff12_ind1 ff12_ind2 ff12_ind3 ff12_ind4 ff12_ind5 ff12_ind6 ff12_ind7 ff12_ind8 ff12_ind9 ff12_ind10 ff12_ind11 ff12_ind12) (NonDurables Durables Manufacturing Energy Chemicals BusEquip Telecoms Utilities Wholesales Healthcare Finance Others)
	gen high_comp=0
	replace high_comp=1 if high_tech==1|Manufacturing==1| Energy==1| Chemicals==1| Wholesales==1| Healthcare==1
	replace cross_country=0 if cross_country==.
	replace diff_sic4=0 if diff_sic4==.
	replace diff_sic3=0 if diff_sic4==.
	
	gen op_test=0
	gen to_test=0
	gen op_to_test=.
	replace op_test=1 if opB4MnA_acq==1
	replace op_test=0 if repB4MnA_acq==0 
	replace to_test=1 if toB4MnA_acq==1
	replace to_test=0 if repB4MnA_acq==0 
	replace op_to_test=1 if to_test==1
	replace op_to_test=0 if op_test==1
	gen x_cc_op_test=op_test*cross_country
	gen x_cc_to_test=to_test*cross_country
	gen x_cc_op_to_test=op_to_test*cross_country
	gen x_sic_op_test=op_test*diff_sic4
	gen x_sic_to_test=to_test*diff_sic4
	gen x_sic_op_to_test=op_to_test*diff_sic4	
	gen x_hc_op_test=op_test*high_comp
	gen x_hc_to_test=to_test*high_comp
	gen x_hc_op_to_test=op_to_test*high_comp
	replace to_test=0 if to_test==.
	replace op_test=0 if op_test==.
	gen wave_to=wavePeriod*to_test
	gen wave_op=wavePeriod*op_test
	

	
	gen calYr=year(dofq(calYrQtr_ef))
	merge m:1 sic calYr using ntrgap
	drop if _merge==2
	gen ntr_sample=cond(_merge==3,1,0)
	drop _merge
	replace ntrgap=0 if ntrgap==.
	replace ntr_sample=0 if ntrgap==0
	tabstat ntrgap, c(s) s(me min p1 p5 p25 p50 p75 p90 p95 p99 max N)
	gen high_ntr=cond(ntrgap>=0.35,1,0)
	gen high_ntr_post=cond(high_ntr==1 & calYr>=2001,1,0)
	gen ntr_sample_post=cond(ntr_sample==1 & calYr>=2001,1,0)
	gen x_hntr_op_test=op_test*high_ntr
	gen x_hntr_to_test=to_test*high_ntr
	gen x_hntr_op_to_test=op_to_test*high_ntr
	gen x_hntrp_op_test=op_test*high_ntr_post
	gen x_hntrp_to_test=to_test*high_ntr_post
	gen x_hntrp_op_to_test=op_to_test*high_ntr_post	
	gen x_ntr_op_test=op_test*ntr_sample
	gen x_ntr_to_test=to_test*ntr_sample
	gen x_ntr_op_to_test=op_to_test*ntr_sample	
	gen x_ntrp_op_test=op_test*ntr_sample_post
	gen x_ntrp_to_test=to_test*ntr_sample_post
	gen x_ntrp_op_to_test=op_to_test*ntr_sample_post	
		
	la var x_hntr_op_test "High comp. M\&A \$ \times \$ Open market" 
	la var x_hntr_to_test "High comp. M\&A \$ \times \$ Tender offer" 
	la var x_hntrp_op_test "High comp. M\&A \$ \times \$ Tender offer" 
	la var x_hntrp_to_test "High comp. M\&A \$ \times \$ Open market" 
	la var x_ntr_op_test "High comp. M\&A \$ \times \$ Open market" 
	la var x_ntr_to_test "High comp. M\&A \$ \times \$ Tender offer"
	la var x_ntrp_op_test "High comp. M\&A \$ \times \$ Open market" 
	la var x_ntrp_to_test "High comp. M\&A \$ \times \$ Tender offer"
	la var high_ntr "High comp. M\&A"
	la var high_ntr_post  "High comp. M\&A"
	la var ntr_sample  "High comp. M\&A"
	la var ntr_sample_post  "High comp. M\&A"
	la var premium_1d "Premium (Announcement-1 day)"
	la var premium_1w "Premium (Announcement-1 week)"
	la var premium_4w "Premium (Announcement-4 weeks)"
	la var diff_sic4 "Cross ind. M\&A"
	la var x_hc_op_test "High comp. M\&A \$ \times \$ Open market" 
	la var x_hc_to_test "High comp. M\&A \$ \times \$ Tender offer"
	la var x_sic_to_test "Cross-industry acquirer \$ \times \$ Tender Offer"
	la var x_cc_to_test "Cross-country acquirer \$ \times \$ Tender Offer"
	la var high_comp "High comp. acquirer"
	la var to_test "Tender offer"
	la var op_test "Open market"
	la var cum_ret1_vw "CAR[-1,+1]"
	la var cum_ret3_vw "CAR[-3,+3]"
	la var cum_ret30_vw "CAR[-30,+30]"
	la var cum_ret60_vw "CAR[-60,+60]" 
*save cov_redesign_car_premium, replace	
	
estimates clear
	eststo: reghdfe cum_ret1_vw to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret3_vw to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret30_vw to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\car_highComp_to_op.tex", replace  b(3) se(3)  ///
	keep( x_hc_to_test ) ///
	order(x_hc_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Ind F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		
		
estimates clear
	eststo: reghdfe cum_ret1_vw to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret3_vw to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret30_vw to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\car_hntr_to_op.tex", replace  b(3) se(3)  ///
	keep( x_hntrp_to_test  ) ///
	order(x_hntrp_to_test  ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Ind F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	

estimates clear
	eststo: reghdfe ret1_vw wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe ret3_vw wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe ret30_vw wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\car_wave_to_op_1.tex", replace  b(3) se(3)  ///
	keep(wave_to ) ///
	order(wave_to) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Ind F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)		
	
estimates clear
	eststo: reghdfe cum_ret1_vw x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret3_vw x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret30_vw x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\car_cind_to_op.tex", replace  b(3) se(3)  ///
	keep( x_sic_to_test ) ///
	order(x_sic_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Ind F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	
	
	estimates clear
	eststo: reghdfe cum_ret1_vw x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret3_vw x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo: reghdfe cum_ret30_vw x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\car_cc_to_op.tex", replace  b(3) se(3)  ///
	keep( x_cc_to_test ) ///
	order(x_cc_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Ind F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	

	
* Premium regressions	
estimates clear	
	qui eststo: reghdfe premium_1d to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo: reghdfe premium_1w to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	qui eststo: reghdfe premium_4w to_test high_comp x_hc_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\premium_acq_highComp.tex", replace  b(3) se(3)  ///
	keep(x_hc_to_test ) ///
	order(x_hc_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	
	
	
	estimates clear	
	qui eststo: reghdfe premium_1d to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo: reghdfe premium_1w to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	qui eststo: reghdfe premium_4w to_test high_ntr_post x_hntrp_to_test ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48) 
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\premium_acq_hntrp.tex", replace  b(3) se(3)  ///
	keep(x_hntrp_to_test ) ///
	order(x_hntrp_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	
	
	
	estimates clear	
	qui eststo: reghdfe premium_1d wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo: reghdfe premium_1w wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	qui eststo: reghdfe premium_4w wave_to to_test wavePeriod ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\tables\premium_acq_wave.tex", replace  b(3) se(3)  ///
	keep(wave_to ) ///
	order(wave_to) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	
		
	
	estimates clear
	eststo: reghdfe premium_1d x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	eststo: reghdfe premium_1w x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	eststo: reghdfe premium_4w x_sic_to_test to_test diff_sic4 ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\premium_acq_xInd_1.tex", replace  b(3) se(3)  ///
	keep(x_sic_to_test ) ///
	order(x_sic_to_test  ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///			
	substitute(\_ _) star(* .1 ** .05 *** .01)	
	
estimates clear
	eststo: reghdfe premium_1d x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	eststo: reghdfe premium_1w x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	eststo: reghdfe premium_4w x_cc_to_test to_test cross_country ln_atq lev cash_at tobinsq , a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE  "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\premium_acq_xcountry.tex", replace  b(3) se(3)  ///
	keep(x_cc_to_test ) ///
	order(x_cc_to_test ) ///
	depvars label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Qtr. F.E." "Industry F.E." )) ///		
	substitute(\_ _) star(* .1 ** .05 *** .01)	
	
***************************************************************************************************************************
* Table 8: CDS returns by competition - collated by Hand
***************************************************************************************************************************

* Identify cross country/industry deals from the SDC dataset

use predictTestSample, clear
	gen fyear=year(dofq(calYrQtr_ef))
	destring gvkey, replace
	collapse (sum) repurchase_dum tenderOffer_dum=tenderOffer openMrkt_dum=openMrkt (median) callDum invGrd remainMaturity intLevel intSlope ln_atq mb lev intCovRatio opCFRatio  roa (max) wavePeriod indCode indCode48, by(gvkey fyear)
tempfile fin_vars
save `fin_vars'

* Get repurchases done by firms in the last 2 years	
clear
use repDates_cp
	collapse (sum) repurchase toffer openMrkt, by(gvkey fyear)
	local vars repurchase toffer openMrkt
	foreach v of local vars{
		replace `v'=1 if `v'>0
	}
tempfile repurchases
save `repurchases'
clear
use gvkey fyear indfmt if indfmt=="INDL" using  compuAnnual
	drop indfmt 
	duplicates drop 
	merge 1:1 gvkey fyear using `repurchases'	
	drop if _merge==2
	drop _merge
	local vars repurchase toffer openMrkt
	foreach v of local vars{
		replace `v'=0 if `v'==.
	}
	rangestat (sum) repurchase toffer openMrkt, interval(fyear -2 0) by(gvkey)
	drop repurchase toffer openMrkt
	rename (repurchase_sum toffer_sum openMrkt_sum) (repurchase toffer openMrkt)
	destring gvkey, replace
tempfile rep_in_past_2yrs	
save `rep_in_past_2yrs'
	
	
* Get Acquirer X repurchase interaction (i.e., acquirers who also repurchased a bond in the last 2 years)	
clear
use repurchase openMrkt effective_date action_type gvkey using fisdSample_MnA_TRACE_cov
	destring gvkey, replace
	drop if gvkey==.
tempfile repurchase_events	
save `repurchase_events'

clear
use sdcMnA_linked
	merge m:1 permco_acq permco_trgt gvkey_acq gvkey_trgt  dateannounced using base_file, keepusing(diff_sic4 diff_sic3 cross_country )
	drop if _merge==2
	drop _merge	
	rename gvkey_acq gvkey
	destring gvkey, replace
	drop if gvkey==.
	joinby gvkey using `repurchase_events', unm(b)
	keep if _merge == 3
	drop _merge
	keep if status=="Completed" | status=="Withdrawn"
	destring  pct_owned_after_trans trans_value, i("-" "," "np") replace
	keep if pct_owned_after_trans !=. & pct_owned_after_trans >=100
	keep if acq_public=="Public" | trg_public=="Public"
	keep if trans_value>=1 & trans_value!=.
	gen check = dateannounced-effective_date
	gen chngB4MnA_acq=cond(check>0&check<=730,1,0)
	gen repB4MnA_acq=cond(action_type=="IRP" | action_type=="T",1,0) if chngB4MnA_acq==1
	replace repB4MnA_acq=0 if repB4MnA_acq==.
	gen toB4MnA_acq=cond(action_type=="T",1,0) if chngB4MnA_acq==1
	gen opB4MnA_acq=cond(action_type=="IRP",1,0) if chngB4MnA_acq==1
	gen to_date=dateannounced if toB4MnA_acq==1
	gen op_date=dateannounced if opB4MnA_acq==1
	gen calYrQtr_ef=yq(year(effective_date), quarter(effective_date))
	format %tq calYrQtr
	drop if gvkey==.
	gen noAcq=1
	replace toB4MnA_acq=0 if toB4MnA_acq==.
	replace opB4MnA_acq=0 if opB4MnA_acq==.
	keep if repB4MnA_acq==1
	
	rename permco_acq permco
	merge m:1 permco using industry,keepusing(indCode48)
	drop if _merge==2
	drop _merge
	merge m:1 indCode48 calYrQtr_ef using wave
	drop if _merge==2
	drop _merge
	replace wavePeriod=0 if wavePeriod==.
	gen wave_to=wavePeriod*toB4MnA_acq
	gen wave_op=wavePeriod*opB4MnA_acq
	collapse (sum) wave_op wave_to wavePeriod toB4MnA_acq opB4MnA_acq repB4MnA_acq diff_sic4 diff_sic3 cross_country, by(gvkey dateannounced)
tempfile acq_rep_events	
save `acq_rep_events'	

* Add CDS spreads	
clear
use cds_us_daily_sprds
	keep gvkey date slope30 slope60 spread1y_me30 spread5y_me30 spread10y_me30 spread1y_me60 spread5y_me60 spread10y_me60 spread1y_me30_pm spread5y_me30_pm spread10y_me30_pm spread1y_me60_pm spread5y_me60_pm spread10y_me60_pm slope30_pm slope60_pm spread1y_me1_pm spread5y_me1_pm spread10y_me1_pm spread1y_me3_pm spread5y_me3_pm spread10y_me3_pm slope1_pm slope3_pm spred_diff_1 spred_diff_3 spred_diff_30 spred_diff_60 liq_diff_1 liq_diff_3 liq_diff_30 liq_diff_60 liq30 liq60 liq30_30 liq60_60 liq1_1 liq3_3 slope30_pm_5_1 slope60_pm_5_1
	rename date dateannounced_treat
	destring gvkey, replace
tempfile cds_spreads
save `cds_spreads'	


* Add all variables to the base matched file
clear
use cds_acq_matches	
	merge m:1 gvkey dateannounced using `acq_rep_events'
	drop if _merge==2
	drop _merge
	merge m:1 gvkey fyear using `rep_in_past_2yrs'
	drop if _merge==2
	drop _merge
	local vars toB4MnA_acq opB4MnA_acq repB4MnA_acq repurchase toffer openMrkt
	foreach v of local vars{
		replace `v'=cond(`v'>0 & `v'!=.,1,0)
	}
	rename wavePeriod wavePeriod_event
	
	merge m:1 gvkey dateannounced_treat using `cds_spreads', keepusing(spread5y_me1_pm spread5y_me3_pm)
	drop if _merge==2
	drop _merge
	
	rename dateannounced_treat date
	merge m:1 gvkey date using cds_us_daily_sprds_short, keepusing(spread1y_me11 spread5y_me11 spread1y_me33 spread5y_me33 spread1y_me01 spread5y_me01 spread1y_me03 spread5y_me03 slope11_5_1 slope33_5_1 slope01_5_1 slope03_5_1 spread1y_me55 spread5y_me55 spread1y_me05 spread5y_me05 slope55_5_1 slope05_5_1)
	drop if _merge==2
	drop _merge
	
	winsor2 spread1y_me11 spread5y_me11 spread1y_me33 spread5y_me33 spread1y_me01 spread5y_me01 spread1y_me03 spread5y_me03 slope11_5_1 slope33_5_1 slope01_5_1 slope03_5_1, cuts(1 99) replace
	
	gen treat_rep=treated*repurchase 
	gen treat_to=treated*toffer 
	gen treat_op=treated*openMrkt 
	
	gen calYrQtr_ef =yq(year(dateannounced), quarter(dateannounced))
	format %tq calYrQtr_ef 
	
	merge m:1 gvkey fyear using `fin_vars', keepusing(ln_atq mb lev wavePeriod roa indCode indCode48 opCFRatio indCode48)
	drop if _merge==2
	drop _merge
	
	drop sic
	rename sic4 sic
	gen high_tech=0
	replace high_tech=1 if sic==7374 | sic==7376 | sic==7377 | sic==7378 | sic==7379 | sic==3660 | sic==3690 | sic==3691 | sic==3692 | sic==3699 | sic==8730 | sic==8731 | sic==8732 | sic==8733 | sic==8734 
	replace high_tech=1 if indCode48==35 | indCode48==36 | indCode48==37 | indCode48==12 | indCode48==13 | indCode48==32 
		
	tab indCode,gen(ff12_ind)
	forvalues i=1/12{
		replace ff12_ind`i'=0 if ff12_ind`i'==1 & high_tech==1
	}
		
	rename (ff12_ind1 ff12_ind2 ff12_ind3 ff12_ind4 ff12_ind5 ff12_ind6 ff12_ind7 ff12_ind8 ff12_ind9 ff12_ind10 ff12_ind11 ff12_ind12) (NonDurables Durables Manufacturing Energy Chemicals BusEquip Telecoms Utilities Wholesales Healthcare Finance Others)
	gen high_comp=0
	replace high_comp=1 if high_tech==1|Manufacturing==1| Energy==1| Chemicals==1| Wholesales==1| Healthcare==1
	replace diff_sic4=0 if diff_sic4==.
	replace cross_country=0 if cross_country==.

	
	gen calYr=year(dofq(calYrQtr_ef))
	merge m:1 sic calYr using ntrgap
	drop if _merge==2
	gen ntr_sample=cond(_merge==3,1,0)
	drop _merge
	replace ntrgap=0 if ntrgap==.
	replace ntr_sample=0 if ntrgap==0
	tabstat ntrgap, c(s) s(me min p1 p5 p25 p50 p75 p90 p95 p99 max N)
	gen high_ntr=cond(ntrgap>=0.35,1,0)
	gen high_ntr_post=cond(high_ntr==1 & calYr>=2001,1,0)
	gen ntr_sample_post=cond(ntr_sample==1 & calYr>=2001,1,0)

	replace wave_op=0 if wave_op==.
	replace wave_to=0 if wave_to==.
	replace wavePeriod_event=0 if wavePeriod_event==.

	local vars treated toffer openMrkt toB4MnA_acq opB4MnA_acq
	foreach v of local vars{
		gen h_`v'=high_comp*`v'
		gen cc_`v'=cross_country*`v'
		gen xind_`v'=diff_sic4*`v'
		gen hntr_`v'=high_ntr*`v'
		gen hntrp_`v'=high_ntr_post*`v' 
		gen ntr_`v'=ntr_sample*`v' 
		gen ntrp_`v'=ntr_sample_post*`v'
	}
		 
	la var spread5y_me11 "5-yr Spread [-1,1]"
	la var spread5y_me33 "5-yr Spread [-3,3]"
	la var spread5y_me55 "5-yr Spread [-5,5]"	
	la var h_toB4MnA_acq "High comp. M\&A \$ \times \$ Acquirer \$ \times \$ Tender offer"
	la var h_opB4MnA_acq "High comp. M\&A \$ \times \$ Acquirer \$ \times \$ Open market"
	la var cc_toB4MnA_acq "Cross-border M\&A \$ \times \$ Acquirer \$ \times \$ Tender offer"
	la var cc_opB4MnA_acq "Cross-border M\&A \$ \times \$ Acquirer \$ \times \$ Open market"
	la var xind_toB4MnA_acq "Cross-ind. M\&A \$ \times \$ Acquirer \$ \times \$ Tender offer"
	la var xind_opB4MnA_acq "Cross-ind. M\&A \$ \times \$ Acquirer \$ \times \$ Open market"
	la var hntrp_toB4MnA_acq "High NTR M\&A \$ \times \$ Acquirer \$ \times \$ Tender offer" 
	la var hntrp_opB4MnA_acq "High NTR M\&A \$ \times \$ Acquirer \$ \times \$ Open market" 
	la var wave_to "Acquirer \$ \times \$ Tender offer in M\&A Wave Qtr."
	la var wave_op "Acquirer \$ \times \$ Open market in M\&A Wave Qtr."
*save cov_redesign_cds, replace	

	estimates clear	
	qui eststo:	reghdfe spread5y_me11 treated toffer toB4MnA_acq high_comp h_treated h_toffer h_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me33 treated toffer toB4MnA_acq high_comp h_treated h_toffer h_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me55 treated toffer toB4MnA_acq high_comp h_treated h_toffer h_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\hcomp_cds_acq.tex", replace  b(3) se(3)  ///
	keep(h_toB4MnA_acq) ///
	order(h_toB4MnA_acq) ///
	label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Announcement Qtr. F.E." "Industry F.E.")) ///					
	substitute(\_ _) star(* .1 ** .05 *** .01)				
						
	estimates clear	
	qui eststo:	reghdfe spread5y_me11 treated toffer toB4MnA_acq high_ntr_post hntrp_treated hntrp_toffer hntrp_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me33 treated toffer toB4MnA_acq high_ntr_post hntrp_treated hntrp_toffer hntrp_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me55 treated toffer toB4MnA_acq high_ntr_post hntrp_treated hntrp_toffer hntrp_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\hntr_cds_acq.tex", replace  b(3) se(3)  ///
	keep(hntrp_toB4MnA_acq) ///
	order(hntrp_toB4MnA_acq) ///
	label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Announcement Qtr. F.E." "Industry F.E.")) ///					
	substitute(\_ _) star(* .1 ** .05 *** .01)									
						
	estimates clear	
	eststo:	reghdfe spread5y_me11 treated toffer toB4MnA_acq wave_to wavePeriod_event ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe spread5y_me33 treated toffer toB4MnA_acq wave_to wavePeriod_event ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	eststo:	reghdfe spread5y_me55 treated toffer toB4MnA_acq wave_to wavePeriod_event ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\wave_cds_acq.tex", replace  b(3) se(3)  ///
	keep(wave_to ) ///
	order(wave_to ) ///
	label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Announcement Qtr. F.E." "Industry F.E.")) ///					
	substitute(\_ _) star(* .1 ** .05 *** .01)				
						
	estimates clear	
	qui eststo:	reghdfe spread5y_me11 treated toffer toB4MnA_acq diff_sic4 xind_treated xind_toffer xind_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me33 treated toffer toB4MnA_acq diff_sic4 xind_treated xind_toffer xind_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me55 treated toffer toB4MnA_acq diff_sic4 xind_treated xind_toffer xind_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\xind_cds_acq.tex", replace  b(3) se(3)  ///
	keep(xind_toB4MnA_acq ) ///
	order(xind_toB4MnA_acq ) ///
	label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Announcement Qtr. F.E." "Industry F.E.")) ///					
	substitute(\_ _) star(* .1 ** .05 *** .01)				
						
	estimates clear	
	qui eststo:	reghdfe spread5y_me11 treated toffer toB4MnA_acq cross_country cc_treated cc_toffer cc_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me33 treated toffer toB4MnA_acq cross_country cc_treated cc_toffer cc_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	qui eststo:	reghdfe spread5y_me55 treated toffer toB4MnA_acq cross_country cc_treated cc_toffer cc_toB4MnA_acq ln_atq lev cash_at tobinsq, a(calYrQtr_ef indCode48) vce(cl indCode48)
	estadd scalar rsqA = `e(r2_a)'
	estadd local yrFE "\$ \checkmark \$"
	estadd local indFE "\$ \checkmark \$"
	esttab using "D:\Dropbox\Bond_Repurchase\tex\M&A_Repurchase\comp_tables\xcountry_cds_acq.tex", replace  b(3) se(3)  ///
	keep(cc_toB4MnA_acq ) ///
	order(cc_toB4MnA_acq ) ///
	label stats(N rsqA yrFE  indFE, fmt(%10.0f %10.3f %12s %12s )  layout(@ @ @ @)  ///
	labels("Obs." "$ Adj.-R^{2} $" "Announcement Qtr. F.E." "Industry F.E.")) ///					
	substitute(\_ _) star(* .1 ** .05 *** .01)				
		